<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width: 600px; margin-top: 100px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-search" title="过滤查询"></i>&nbsp;&nbsp;<span>门店员工&nbsp;-&nbsp;过滤查询</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="GET" action="${ctx.host}/principals" data-validate="true">

      <input type="hidden" name="filter" value="true" >

      <div class="modal-body">

        <c:if test="${empty currentPrincipal.site}">
          <div class="form-group x-form-group">
            <label class="col-xs-4 control-label">门店</label>
            <div class="pull-left col-xs-6">
              <select name="siteId" class="form-control">
                <option value="">所有门店</option>
                  <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                    <option value="${site.id}" ${site.id == param.siteId ? 'selected' : ''}>${site.name}</option>
                  </c:forEach>
              </select>
            </div>
          </div>
        </c:if>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">姓名</label>
          <div class="pull-left col-xs-6">
            <input type="text" class="form-control" name="name" value="${param.name}" placeholder="支持模糊查询" />
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">角色</label>
          <div class="pull-left col-xs-6">
            <select name="authority" class="form-control">
              <option></option>
              <c:if test="${currentPrincipal.root or currentPrincipal.admin}">
                <option value="ROLE_AREA_MANAGER" ${param.authority == 'ROLE_AREA_MANAGER' ? 'selected' : ''}>大店长</option>
                <option value="ROLE_AREA_SERVER" ${param.authority == 'ROLE_AREA_SERVER' ? 'selected' : ''}>运营主管</option>
              </c:if>
              <c:if test="${currentPrincipal.root or currentPrincipal.admin or currentPrincipal.areaManager}">
                <option value="ROLE_SITE_MANAGER" ${param.authority == 'ROLE_SITE_MANAGER' ? 'selected' : ''}>店长</option>
              </c:if>
              <option value="ROLE_COACH" ${param.authority == 'ROLE_COACH' ? 'selected' : ''}>教练</option>
              <option value="ROLE_SITE_SERVER" ${param.authority == 'ROLE_SITE_SERVER' ? 'selected' : ''}>门店客服</option>
            </select>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-4 control-label">状态</label>
          <div class="pull-left col-xs-6">
            <select name="disabled" class="form-control">
              <option></option>
              <option value="false" ${param.disabled == 'false' ? 'selected' : ''}>未锁定</option>
              <option value="true" ${param.disabled == 'true' ? 'selected' : ''}>锁定</option>
            </select>
          </div>
        </div>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">查询</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>

    </form>
  </div>
</div>

<script type="text/javascript">
  
  $(document).ready(function(){
      
      $('select[name="siteId"]').select2({
            placeholder : '请选择门店',
            minimumResultsForSearch : -1,
            allowClear : true,
          });

      $('select[name="authority"]').select2({
          placeholder : '请选择角色',
          minimumResultsForSearch : -1,
          allowClear : true
      });
      
      $('select[name="disabled"]').select2({
          placeholder : '请选择状态',
          minimumResultsForSearch : -1,
          allowClear : true
      });
  })
  
</script>
  
